<template>
  <div v-if="prevBlog || nextBlog" class="blog-navigation">
    <div v-if="prevBlog" class="navigation-item prev">
      <span>上一篇</span>
      <a :href="`#/blog/${prevBlog.id}`">{{ prevBlog.title }}</a>
    </div>
    <div v-if="nextBlog" class="navigation-item next">
      <span>下一篇</span>
      <a :href="`#/blog/${nextBlog.id}`">{{ nextBlog.title }}</a>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from 'vue'

// 定义组件的属性
const props = defineProps({
  prevBlog: {
    type: Object,
    required: false,
    default: null
  },
  nextBlog: {
    type: Object,
    required: false,
    default: null
  }
})
</script>

<style scoped>
.blog-navigation {
  background: white;
  border-radius: 12px;
  padding: 24px 32px;
  margin: 32px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.navigation-item {
  flex: 1;
  min-width: 200px;
}

.navigation-item.prev {
  text-align: left;
}

.navigation-item.next {
  text-align: right;
}

.navigation-item span {
  display: block;
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.navigation-item a {
  color: #333;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navigation-item a:hover {
  color: #1890ff;
  transform: translateX(4px);
}

.navigation-item.prev a:hover {
  transform: translateX(-4px);
}

@media (max-width: 768px) {
  .blog-navigation {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  
  .navigation-item {
    min-width: auto;
  }
  
  .navigation-item.prev,
  .navigation-item.next {
    text-align: left;
  }
}
</style>